package com.finance.scheduler.job;

import com.finance.base.enums.FeeCommitStateEnum;
import com.finance.logistics.computer.DataExtractor;
import com.finance.framework.qurtz.TaskDescriptor;
import com.finance.logistics.computer.DataExtractorParam;
import com.finance.scheduler.service.AbstractTask;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 抽取已经拉取的运单信息
 */
@Component
@DisallowConcurrentExecution
public class ErrorDataRecomputeJob implements AbstractTask{
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private DataExtractor dataExtractor;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("**********************计算错误数据重新计算调度开始执行*********************");
        DataExtractorParam dataExtractorParam = new DataExtractorParam.Builder().signDate(new Date()).feeCommited(FeeCommitStateEnum.ERROR.getState()).build();
        this.dataExtractor.extract2compute(dataExtractorParam);
        logger.info("**********************计算错误数据重新计算调度结束执行*********************");
    }

    @Override
    public TaskDescriptor descriptor() {
        return new TaskDescriptor("计算失败数据再计算","default","extractErrorData_trigger","extractErrorData_trigger","0 0 0 4 * ?",this.getClass().getCanonicalName(),"处理已经异常的运单数据，通常是规则未匹配的");
    }

}
